package se.webbzon.boltzmann.game.object.dialogue.word;

import java.awt.Color;
import java.awt.Dimension;

import se.webbzon.boltzmann.game.object.dialogue.AbstractDialogue;
import se.webbzon.boltzmann.game.object.dialogue.layout.DialogueLayout;
import se.webbzon.oschi01.worldobject.appearance.TextAppearance3D;

public class SmallDialogueWord extends SimpleDialogueWord {
		
	/*============================================================
	Constructors
	============================================================*/
	
	/** Creates a new small dialogue word with the default color. **/
	public SmallDialogueWord(DialogueLayout layout, String word) {
		super(layout,word);
	}
	
	/** Creates a new small dialogue word with a given color. **/
	public SmallDialogueWord(DialogueLayout layout, String word, Color color) {
		super(layout,word,color);
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	@Override public void getDimension(Dimension d) {
		final DialogueLayout layout = getLayout();
		d.setSize(	0.5 * getWord().length() * layout.getCharacterWidth(),
					0.5 * layout.getCharacterHeight());
	}
	
	@Override public void onShowCharacter(AbstractDialogue dialogue, int character) {
		DialogueLayout layout = getLayout();
		TextAppearance3D appearance = (TextAppearance3D) getAppearance();
		appearance.setText(getWord().substring(0, character));
		
		setSize(0.5 * layout.getCharacterWidth() * character,
				0.5 * layout.getCharacterHeight(),
				1);
	}
	
}
